package com.supermali.behavior.goback.land;

import com.supermali.behavior.forward.land.MoveRateControl;
import com.supermali.behavior.goback.GobackBehavior;
import com.supermali.entity.npc.person.Person;

public class LandPersonGoBack extends GobackBehavior {

    private Person person;
    MoveRateControl moveRateControl;

    public LandPersonGoBack(Person person) {
        this.person = person;
        this.moveRateControl = new MoveRateControl();
    }

    @Override
    public void goback(long delta) {
        person.setDirect(Person.Direct.Left);
        person.setRunState(Person.RunState.GOBACK);
        // 前进
        double x = person.getX();
        if(x >0){
            double move = moveRateControl.move(delta, -1);
            x+=move;
            person.setX(x);
        }
    }
}
